home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / croutes.zip / NAMES.C < prev    next >
Text File  |  1984-07-29  |  5KB  |  196 lines

  1. /*****************************************************************
  2.  *  The following program is not intended on how to write a good *
  3.  *  c program and there are many people out there who are   many *
  4.  *  many times better c programmers than I will ever be. Most of *
  5.  *  the questions I get on my BBS from new c programmers is "how *
  6.  *  do I get output to disk.  There seems to be a lot of confus- *
  7.  *  ion in this area.  Therefor I wrote this little program with *
  8.  *  the hope that it might clear up some of the  questions  some *
  9.  *  of you may have in the area.  It is the common name and addr *
  10.  *  data entry program.  It was compiled with the DeSemet c com- *
  11.  *  piler.  The output is a disk file on drive B that has  null  *
  12.  *  characters between the fields and a cr/lf at the end of the  *
  13.  *  record.     Hope it helps and have fun.  Lynn Long           *
  14.  *****************************************************************/
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. static char *notes[6] = {
  29.     "BUILD NAME AND ADDRESS FILE",
  30.     "By Lynn Long",
  31.     "Tulsa IBM-IBBS"
  32.     "918-749-0718",
  33.     "Press Any Key To Continue",
  34.     "All Names Entered? "
  35.     };
  36.  
  37. #include "stdio.h"
  38. FILE *fd;
  39. char buff[50];
  40. char *input;
  41. #define COMMA    44
  42. #define ESCAPE  0x1b
  43. main()
  44.  
  45. {
  46.     int t;
  47.     char c;
  48.     hedrnote();
  49.     c=getchar();
  50.     if((fd=fopen("b:names.dat","wb")) < 0) {
  51.         printf("Error in creating n&a file");
  52.         exit(1);
  53.     }
  54.     t=TRUE;
  55.     do {
  56.         t = bldfil();
  57.        }while(t);
  58.     fclose(fd);
  59.     scr_clr();
  60. }
  61. hedrnote()
  62. {
  63.     frame(8,20,8,40);
  64.     scr_rowcol(10,26);
  65.     printf(notes[0]);
  66.     scr_rowcol(11,34);
  67.     printf(notes[1]);
  68.     scr_rowcol(12,33);
  69.     printf(notes[2]);
  70.     scr_rowcol(13,34);
  71.     printf(notes[3]);
  72.     scr_rowcol(22,27);
  73.     printf(notes[4]);
  74.  
  75.  
  76.  
  77. }
  78. bldfil(t)
  79. int t;
  80. {
  81.  
  82.     char d;    
  83.  
  84.     frame(6,20,15,40);
  85.     scr_rowcol(8,26);
  86.     printf("FIRST NAME:");
  87.     scr_rowcol(10,26);
  88.     printf("LAST NAME:");
  89.     scr_rowcol(12,26);
  90.     printf("ADDRESS:");
  91.     scr_rowcol(14,26);
  92.     printf("CITY:");
  93.     scr_rowcol(16,26);
  94.     printf("STATE:");
  95.     scr_rowcol(18,26);
  96.     printf("ZIP CODE:");
  97.     scr_rowcol(8,40);
  98.     gets(buff);
  99.     putout();
  100.     scr_rowcol(10,40);
  101.     gets(buff);
  102.     putout();
  103.     scr_rowcol(12,40);
  104.     gets(buff);
  105.     putout();
  106.     scr_rowcol(14,40);
  107.     gets(buff);
  108.     putout();
  109.     scr_rowcol(16,40);
  110.     gets(buff);
  111.     putout();
  112.     scr_rowcol(18,40);
  113.     gets(buff);
  114.     putout();
  115.     scr_rowcol(22,30);
  116.     printf(notes[5]);
  117.     putc('\n', fd);
  118.     putc('\r', fd);
  119.     d=getchar();
  120.     if(d == 'y')
  121.         t=FALSE;
  122.     else
  123.         t=TRUE;
  124.     return(t);
  125. }
  126. putout()
  127. {
  128.     input = buff;
  129.     do {
  130.             putc(*input, fd);
  131.         }while(*input++);
  132.  
  133. }
  134. /**********************************************************
  135.  *   This function builds a nice looking frame for a      *
  136.  *   menu.  The function is passed the parameters for     *
  137.  *   the upper left corner row, upper left corner column  *
  138.  *   the height of the frame and the width.  Depending    *
  139.  *   on your particular compiler characteristics you      *
  140.  *   will have to substitute its functions for clear-     *
  141.  *   ing the screen and locating at the correct row       *
  142.  *   and column on the screen. the functions you will     *
  143.  *   need to replace with your own are scr_clr() and      *
  144.  *   scr_rowcol(x, y).                                    *
  145.  *                                                        *
  146.  *          Program By                                    *
  147.  *          Lynn Long                                     *
  148.  *          Tulsa, OK RBBS "C" Bulletin Board             *
  149.  *          918-749-0718                                  *
  150.  *********************************************************/
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. #define            ULCOR            201
  161. #define            URCOR            187
  162. #define            LLCOR            200
  163. #define            LRCOR            188
  164. #define            VBAR            186
  165. #define            HBAR            205
  166.  
  167. frame(row, col, hgt, wdth)
  168. int row, col, hgt, wdth;
  169.  
  170. {
  171.     int x, y;
  172.     
  173.  
  174.     scr_clr();                                /*  insert your code here to clear screen  */
  175.     scr_rowcol(row, col);                     /*  insert your function to locate row and col */
  176.     putchar(ULCOR);
  177.     for(x = col + 1; x <=(col + wdth -1); x++)
  178.          putchar(HBAR);
  179.         putchar(URCOR);
  180.         for(x = row + 1; x <=(row + hgt - 1); x++){
  181.         scr_rowcol(x, col);    
  182.         putchar(VBAR);
  183.         scr_rowcol(x, col+wdth);
  184.         putchar(VBAR);
  185.    }
  186.     scr_rowcol(x, col);  
  187.     putchar(LLCOR);
  188.     for(x= col + 1; x <=(col + wdth -1); x++)
  189.         putchar(HBAR);
  190.         putchar(LRCOR);    
  191. col + 1; x <=(col + wdth -1); x++)
  192.         putchar(HBAR);
  193.         putchar(LRCOR);